/**
 *  bcd_is_bcd()
 *  je to BCD?
 */
char bcd_is_bcd() {
  return (cmos_read(0x0B) & 0x02);
}

/**
 *  bcd_read()
 *  cti byte z CMOS a zkonvertuj do BCD
 */
char bcd_read(unsigned int reg) {
  unsigned int in = cmos_read(reg);
  if(bcd_is_bcd())
    return (in >> 4) * 10 + (in & 15);
  else
    return in;
}

/**
 *  bcd_write()
 *  zapis BCD data do CMOS
 */
void bcd_write(unsigned int reg, unsigned int data) {
  if(bcd_is_bcd())
    cmos_write(reg, ((data/10) << 4) | (data%10));
  else
    cmos_write(reg, data);
  return;
}
